package com.zc.oss.controller;

import com.zc.oss.service.OssService;
import com.zc.utils.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(description = "Oss上传文件")
@RestController
@RequestMapping("/oss/fileOss/")
@CrossOrigin
public class OssController {

	@Autowired
	private OssService ossService;

	// 上传头像
	@PostMapping("/upload")
	public R uploadFile(MultipartFile file) {
		String url = ossService.uploadAvatar(file);
		return R.ok().data("url", url);
	}
}
